Skip to content

refactor(ovn_leader_checker): improve readability and naming#6263

Merged
oilbeater merged 1 commit intomasterfrom
refactor/ovn-leader-checker-refactor
Feb 9, 2026
Merged

refactor(ovn_leader_checker): improve readability and naming#6263
oilbeater merged 1 commit intomasterfrom
refactor/ovn-leader-checker-refactor

Conversation

@oilbeater
Copy link
Copy Markdown
Collaborator

Summary

Refactor pkg/ovn_leader_checker/ovn.go for readability and naming.

Changes

  • Add northdDialTimeout constant for northd dial timeout
  • Rename Configuration.ISICDBServer to IsICDBServer
  • In getCmdExitCode: use if err := cmd.Run(); err != nil; log clear message when ProcessState is nil
  • In checkOvnIsAlive: use exitCode != 0 instead of err
  • In getTSCidr: return directly in switch and return error for unsupported protocol

Made with Cursor

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Feb 4, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @oilbeater, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on enhancing the readability and maintainability of the ovn.go file within the ovn_leader_checker package. The changes involve adopting better naming conventions, introducing a constant for a magic number, refining error messages for clarity, and streamlining conditional logic in several functions. These improvements aim to make the codebase easier to understand and manage for future development.

Highlights

  • Constant Introduction: A new constant, northdDialTimeout, has been introduced to centralize the network dial timeout duration, replacing a hardcoded value and improving maintainability.
  • Naming Convention Adherence: The ISICDBServer field within the Configuration struct has been renamed to IsICDBServer to align with Go's idiomatic naming conventions (camelCase for struct fields).
  • Improved Error Handling and Clarity: Error logging in getCmdExitCode has been enhanced to provide a more specific message when ProcessState is unavailable. Additionally, the variable name for the command exit code in checkOvnIsAlive was clarified from err to exitCode.
  • Refactored Logic for getTSCidr: The getTSCidr function has been refactored to directly return CIDR values within its switch statement and now explicitly returns an error for unsupported protocols, simplifying its logic and improving error handling.
Changelog
  • pkg/ovn_leader_checker/ovn.go
    • Added northdDialTimeout constant (3 seconds) for network dial operations.
    • Renamed Configuration.ISICDBServer to Configuration.IsICDBServer to follow Go naming conventions.
    • Updated all references to ISICDBServer to IsICDBServer.
    • Refactored getCmdExitCode to use if err := cmd.Run() syntax and provide a more descriptive error message when cmd.ProcessState is nil.
    • Changed variable name from err to exitCode when calling getCmdExitCode in checkOvnIsAlive for better semantic clarity.
    • Replaced hardcoded 3*time.Second with the northdDialTimeout constant in checkNorthdEpAvailable.
    • Modified getTSCidr to directly return the CIDR string within the switch statement and added an explicit error return for unsupported protocols.
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several good refactorings that improve code readability and correctness. The introduction of the northdDialTimeout constant, renaming ISICDBServer to the more idiomatic IsICDBServer, and improvements to logging and error handling in getCmdExitCode and getTSCidr are all positive changes. I've identified one area for further improvement in getCmdExitCode to make it more robust in handling non-zero exit codes.

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 21675291363

Details

  • 0 of 12 (0.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage remained the same at 23.038%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/ovn_leader_checker/ovn.go 0 12 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/ovn_leader_checker/ovn.go 1 0.0%
Totals Coverage Status
Change from base Build 21669073441: 0.0%
Covered Lines: 12438
Relevant Lines: 53989

💛 - Coveralls

- Add northdDialTimeout constant for northd dial timeout
- Rename Configuration.ISICDBServer to IsICDBServer
- In getCmdExitCode: use if err := cmd.Run(); err != nil; log clear message when ProcessState is nil
- In checkOvnIsAlive: use exitCode != 0 instead of err
- In getTSCidr: return directly in switch and return error for unsupported protocol

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
@oilbeater oilbeater force-pushed the refactor/ovn-leader-checker-refactor branch from 0a1e2fe to 50167b9 Compare February 9, 2026 10:15
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Feb 9, 2026
@oilbeater oilbeater merged commit 7dfd023 into master Feb 9, 2026
144 of 148 checks passed
@oilbeater oilbeater deleted the refactor/ovn-leader-checker-refactor branch February 9, 2026 13:18
oilbeater added a commit that referenced this pull request Feb 10, 2026
- Add northdDialTimeout constant for northd dial timeout
- Rename Configuration.ISICDBServer to IsICDBServer
- In getCmdExitCode: use if err := cmd.Run(); err != nil; log clear message when ProcessState is nil
- In checkOvnIsAlive: use exitCode != 0 instead of err
- In getTSCidr: return directly in switch and return error for unsupported protocol

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 7dfd023)
zbb88888 pushed a commit to qiniu/kube-ovn that referenced this pull request Apr 8, 2026
…#6263)

- Add northdDialTimeout constant for northd dial timeout
- Rename Configuration.ISICDBServer to IsICDBServer
- In getCmdExitCode: use if err := cmd.Run(); err != nil; log clear message when ProcessState is nil
- In checkOvnIsAlive: use exitCode != 0 instead of err
- In getTSCidr: return directly in switch and return error for unsupported protocol

Signed-off-by: Mengxin Liu <liumengxinfly@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 7dfd023)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants